﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using System.ComponentModel;

namespace Skynet.WebAdministracion.Views.ExamEndViewer
{
    [System.ComponentModel.DataObject]
    public class ExamEndViewerPresenter : Infrastructure.Web.Views.Master.MasterPresenter<IExamEndViewer>
    {
        [Dependency]
        public WebFoundation.Services.Session.ISessionService SessionService { get; set; }

        [Dependency]
        public WebFoundation.Services.Navigation.INavigationService NavigationService { get; set; }

        [Dependency]
        public BusinessLogic.BusinessComponents.IBCExamQueries BCExamQueries { get; set; }

        public override void OnViewInitialized()
        {
         
        }
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public object GetActiveExams(Guid RuntimeExamByCustomerId)
        {

            var EBC = this.BCExamQueries.SearchExamByCustomer(BusinessLogic.BusinessComponents.ExamByCustomerSearchOptions.GetByExamByCustomerId, ExamByCustomerId: RuntimeExamByCustomerId).SingleOrDefault();
            var result = new {Id=EBC.Id, Title = EBC.Exam.Title, Duration = EBC.Duration, ValidFrom = EBC.ValidFrom, ValidTo = EBC.ValidTo, Score = EBC.Score };
            return result;
        }

        public void FinishExam()
        {
            this.NavigationService.NavigateRoute(Constants.RoutesNames.Home);
        }
    }
}
